﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/static/include/topLess.jsp"%>
<script>document.title="企业列表";</script>
<script type="text/javascript">

$("#title").val("${param['title']}");
$("#dday").val("${param['dday']}");

function saveForm(sysId,cateId){
	var ids = "";
	var ee = document.myform.list2;
    for(var i=0;i<ee.options.length;i++){
    	var e = ee.options[i];
        ids = ids + e.value + "," ;   
    } 
    var users = "";
    var ff = document.myform.list4;
    for(var i=0;i<ff.options.length;i++){
    	var f = ff.options[i];
    	users = users + f.value + "," ;   
    } 
    
    if ($("#title").val()==""){
    	layer.alert("请填写催报标题");    	
    	return;
    }
    if (ids==""){
    	layer.alert("请选择报表");
    	return;
    }
    if (users==""){
    	layer.alert("请选择催报单位");
    	return;
    }
    
	//alert(ids);
	$("#users").attr("value",users);
	$("#ids").attr("value",ids);
	$("#sysValue").attr("value",sysId);
	$("#xlValue").attr("value",cateId);
	
	var url = "${baseURL}/monitor/saveCb";
	var data = {users:users, ids:ids, sysValue:sysId, xlValue:cateId, dday:$("#dday").val(), title:$("#title").val(),date:$("#reportDate").val()};
	$.post(url, data, function(msg){
		if (msg!=""){
			layer.msg("发布成功", 1, 1, closeWin);
		}
	});
}
function openEditWin(id){
	openWin("修改详情","edit?id="+id,600,500);
}
function openViewWin(id){
	openWin("查看详情","view?id="+id,600,500);
}
function changeDl(dlId) {
	//alert("111");
	//alert(dlId);
	//alert(ptype);
	$.getJSON("${baseURL}/monitor/changeDl?dlId="+dlId, function(data) {
		$("#cateId").empty();
		$("#cateId").append( "<option value='0'>..</option>" );
		//alert(data);
	 	$.each(data, function(i, item) {
            $("#cateId").append( "<option value='" + item.id + "'>" + item.dustryName + "</option>" );
        });
 });
}
function changeXl(industryId,code,date) {
	//alert(industryId);
	//alert(code);
	//alert(version);
	$.getJSON("${baseURL}/monitor/changeXl?industryId="+industryId+"&code="+code+"&date="+date, function(data) {
		$("#list1").empty();
	 	$.each(data, function(i, item) {
            $("#list1").append( "<option value='" + item.id + "'>" + item.typeName + "</option>" );
        });
 });
	
}

function moveOption(e1, e2){
    try{
        for(var i=0;i<e1.options.length;i++){
            if(e1.options[i].selected){
                var e = e1.options[i];
                e2.options.add(new Option(e.text, e.value));
                e1.remove(i);
                i=i-1;
            }
        }
    }
    catch(e){}
}
function changeVs(sysId,vsId) {
	var sysId=$("#sysId").val();
	var vsId=$("#reportDate").val();
	$.getJSON("${baseURL}/monitor/changeRsForDate?sysId="+sysId+"&date="+vsId, function(data) {
		$("#list1").empty();
	 	$.each(data, function(i, item) {
            $("#list1").append( "<option value='" + item.id + "'>" + item.typeName + "</option>" );
        });
 });
}
/**function changeVs(sysId,vsId) {
	
	$.getJSON("${baseURL}/monitor/changeVsToData?sysId="+sysId+"&vsId="+vsId, function(data) {
		$("#list1").empty();
	 	$.each(data, function(i, item) {
            $("#list1").append( "<option value='" + item.id + "'>" + item.typeName + "</option>" );
        });
 });
}*/
function queryUnitData(){
	var url = "${baseURL}/unit/queryAllUsersByIndustryId";
	$.post(url, {areaId:'${sessionScope.user.userUnitId}'}, function(data){
		$("#list3").empty();
		$.each(data, function(i, item){
			var unitName = item.unitName;
			
			if ($("#unitName").val()!=""){
				if (unitName.indexOf($("#unitName").val())>-1){
					$("#list3").append( "<option value='" + item.id + "'>" + unitName + "</option>" );
				}
			}else{
				$("#list3").append( "<option value='" + item.id + "'>" + unitName + "</option>" );
			}			 
		});
	}, 'json');
}
</script>
<form name="myform" action="${baseURL}/monitor/saveCb" method="post">
	<input type="hidden" id="ids" name="ids" value="" />
	<input type="hidden" id="users" name="users" value="" />
	<input type="hidden" id="sysValue" name="sysValue" value="" />
	<input type="hidden" id="xlValue" name="xlValue" value="" />
		
<table>
	<tbody>
		<tr>
			<th><img src="${ctx}/static/images/pages/cen/rig/ico_01.png"
				align="absmiddle">&nbsp;设置报表催报</th>
		</tr>
		<tr class="tab_grey">
			<td>
			<img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />标题：
			<input type="text" name="title" id="title" value="${param['title']}" size="20" style="width:160px" class="but_sh"/>
			&nbsp;&nbsp;&nbsp;
			
			<img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />报送延迟(天)：
			<input type="text" name="dday" id="dday" value="${param['dday']}" size="20" class="but_sh"/>
			&nbsp;&nbsp;&nbsp;
			
			<img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />报表制度：
			<select id="sysId" name="sysId" style="width:180px" onchange="changeVs($('#sysId').val(),$('#reportDate').val());">
               <c:forEach var="sys" items="${sysList}">
                   <option value="${sys.code}">${sys.codeName}</option>
               </c:forEach>
           </select>
           <br />
            <img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />报表日期
				<input type="text" name="reportDate" id="reportDate" value="${reportDate}" size="20" onclick="WdatePicker({dateFmt:'yyyy-MM',minDate:'1995-01-01',maxDate:'%y-%M-%d',onpicked:changeVs})" class="Wdate"/>
      <!-- <img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />报表版本：
			<select id="vsId" name="vsId" style="width:140px" onchange="changeVs($('#sysId').val(),$('#vsId').val());">
               <c:forEach var="vs" items="${vsList}">
                   <option value="${vs.id}">${vs.versionSystem}</option>
               </c:forEach>
           </select> -->	
			&nbsp;&nbsp;&nbsp;
			<img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />产业主要类别：
			<select style="width:150px" id="dlId" name="dlId" onchange="changeDl($('#dlId').val());">
               <c:forEach var="dl" items="${dlList}">
                   <option value="${dl.code}">${dl.dustryName}</option>
               </c:forEach>
           </select>
           &nbsp;&nbsp;&nbsp;
			<img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />产业分类：
			<select id="cateId" name="cateId" style="width:170px" onchange="changeXl($('#cateId').val(),$('#sysId').val(),$('#reportDate').val());">
               <option value="">...</option>
               <c:forEach var="ca" items="${cateList}">
               	   <c:if test="${ca.code==1}">
                   <option value="${ca.id}">${ca.dustryName}</option>
                   </c:if>
               </c:forEach>
           </select>
           &nbsp;&nbsp;&nbsp;
           <a class="tab_but" href="#" onclick="saveForm($('#sysId').val(),$('#cateId').val());">保存</a>      
    </td>
    </tr>
    </tbody>
</table>
  <br />
  
  <table style="width:900px">
    <tr>
      <td width="40%">
        <select id="list1" style="width:100%;" multiple name="list1" size="12" ondblclick="moveOption(document.myform.list1, document.myform.list2)">
            <c:forEach var="rp" items="${rpList}">
                   <option value="${rp.id}">${rp.typeName}</option>
            </c:forEach>  
        </select>
      </td>
      <td width="20%" align="center">
        <input type="button" value="添加报表" onclick="moveOption(document.myform.list1, document.myform.list2)">
 
 
        <input type="button" value="删除报表" onclick="moveOption(document.myform.list2, document.myform.list1)">
      </td>
      <td width="40%">
        <select id="list2" style="width:100%;" multiple name="list2" size="12" ondblclick="moveOption(document.myform.list2, document.myform.list1)">
             
        </select>
      </td>
    </tr>
  </table>
  
  <br>
  
  <table style="width:900px">
    <c:if test="${runMode=='WEB'}">
    <tr>
    	<td colspan="3">
    	<span class="tab_text">单位名称查询：</span>
    	<input type="text" id="unitName" name="unitName" class="tab_textbut_200"> 
    	<a class="tab_but" href="#" onclick="queryUnitData();return false;">查询</a>
    	</td>
    </tr>
    </c:if> 
  
    <tr>
      <td width="40%">
        <select id="list3" style="width:100%;" multiple name="list3" size="12" ondblclick="moveOption(document.myform.list3, document.myform.list4)">
           
           <c:if test="${runMode=='LAN'}">
           <c:forEach var="uni" items="${unitList}">
                   <option value="${uni.id}">${uni.unitName}</option>
            </c:forEach>
            </c:if>
        </select>
      </td>
      <td width="20%" align="center">
        <input type="button" value="添加单位" onclick="moveOption(document.myform.list3, document.myform.list4)">
 
 
        <input type="button" value="删除单位" onclick="moveOption(document.myform.list4, document.myform.list3)">
      </td>
      <td width="40%">
        <select id="list4" style="width:100%;" multiple name="list4" size="12" ondblclick="moveOption(document.myform.list4, document.myform.list3)">
             
        </select>
      </td>
    </tr>
  </table>
</form>

<%@ include file="/static/include/bottom.jsp"%>
